<template>
  <div>
    <!-- v-if="this.list.evalTaskId && this.row.progress >= 0 && row.evalMode !== 2" -->
    <el-button
      v-if="this.list.targetId"
      class="fr mb20"
      @click="startEval(list, 'evaluate')"
      type="primary"
    >开始考评</el-button>
    <e-table :tableData="tableData" :columns="columns" :loading="loading" :pageObj="null">
      <el-table-column slot="submitTime" label="提交时间" width="150" align="center">
        <template
          slot-scope="scope"
        >{{ scope.row.submitTime ? formatTime(scope.row.submitTime) : null }}</template>
      </el-table-column>
      <el-table-column fixed="right" slot="action" label="操作" width="60" align="center">
        <template slot-scope="scope">
          <a @click="startEval(scope.row, 'detail')">详情</a>
        </template>
      </el-table-column>
    </e-table>
  </div>
</template>

<script>
import { startInternal } from '@/api/satisfaction'

import { getSession, setSession, judgeEvalState, judgeType, formatY } from '@/utils/util'

export default {
  props: {
    list: {
      type: Object
    }
  },
  watch: {
    list: {
      handler(n, o) {
        console.log('list new', n)
      }
    }
  },
  created() {
    if (this.list && this.list.internalNoteVOList) {
      this.tableData = this.list.internalNoteVOList
    } else {
      this.tableData = []
    }
  },
  data() {
    return {
      loading: false,
      columns: [
        {
          label: '项目名称',
          prop: 'internalItemName'
        },
        {
          label: '等级名称',
          prop: 'internalLevelName'
        },
        {
          label: '评价理由',
          prop: 'reason'
        },
        { slot: 'submitTime' },

        { slot: 'action' }
      ],
      tableData: [],
      row: this.$route.params.row || getSession('evalListRow')
    }
  },
  methods: {
    handleStartEval() {},
    judgeType(num) {
      return judgeType(num)
    },
    judgeState(num) {
      return judgeEvalState(num)
    },
    startEval(row, type) {
      console.log('传递row', row)

      this.$router.push({
        name: 'satisfactionStartTest',
        params: { row, type }
      })
    }
  }
}
</script>
